﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;
namespace AnyOffice.general.system.user_priv
{
    public partial class edit : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                int num = (Request.QueryString["priv_id"] == null) ? 0 : int.Parse(Request.QueryString["priv_id"].ToString());
                this.ViewState["PrivId"] = num;
                ConfigManager manager = new ConfigManager();
                int administratorPrivId = manager.AdministratorPrivId;
                if (num == administratorPrivId)
                {
                    this.litPrompt.Text = base.ShowPromptNoNav("本角色为内置的‘超级系统管理员’角色，具有特殊的职能，为admin用户的默认角色，可以编辑其名称，但应保留其‘超级系统管理员’内涵").Replace("180", "300");
                }
                DataTable table = new UserPrivDao().SelectByPrivId(base.Conn, num);
                if (table.Rows.Count > 0)
                {
                    this.txtPrivNo.Text = table.Rows[0]["PrivNo"].ToString();
                    this.txtPrivName.Text = table.Rows[0]["PrivName"].ToString();
                    this.ViewState["FuncIdStr"] = table.Rows[0]["FuncIdStr"].ToString();
                }
            }
            if (this.Page.IsPostBack)
            {
                this.pnlMain.Visible = false;
                UserPrivDao dao2 = new UserPrivDao();
                UserPrivData data = new UserPrivData();
                data.PrivId = Convert.ToInt32(this.ViewState["PrivId"].ToString());
                data.PrivNo = Convert.ToInt32(this.txtPrivNo.Text);
                data.PrivName = this.txtPrivName.Text;
                data.FuncIdStr = this.ViewState["FuncIdStr"].ToString();
                dao2.Update(base.Conn, data);
                this.lblMessage.Text = base.ShowPrompt("编辑角色成功!", "index.aspx");
            }
        }
    }
}
